package com.woniuxy.factory.controller;

import com.woniuxy.factory.entity.Planunit;
import com.woniuxy.factory.entity.ProductionPlan;
import com.woniuxy.factory.entity.ResponseResult;
import com.woniuxy.factory.service.MissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/mission")
public class MissionController {

    @Autowired
    MissionService ms;

    //查询所有的计划单
    @ResponseBody
    @RequestMapping("/allmission")
    public ResponseResult selectMission(ProductionPlan productionPlan,int page,int limit){
        //查询计划单
        List<ProductionPlan> pp = ms.selectMission(productionPlan,page,limit);
        //查询计划单总数
        int count = ms.selectMissionSum(productionPlan);
        ResponseResult rr = new ResponseResult(0,"",count,pp);
        return rr;
    }

    //查询当前计划单里的所有计划项
    @ResponseBody
    @RequestMapping("/planunit")
    public ResponseResult selectMissionById(String id,int page,int limit){
        System.out.println(id+","+page+","+limit);
        System.out.println("哈绝地反击阿萨德了解付款");
        List<Planunit> lp = ms.selectPlanunit(id,page,limit);
        int count = ms.selectPlanunitSum(id);
        ResponseResult rr = new ResponseResult(0,"",count,lp);
        return rr;
    }
}
